import React from "react";
// NavLink和Link一样可以跳转，选中的时候会多一个active类名
import { NavLink, Routes, Route } from "react-router-dom";
import "./07-style.css";

const Home = () => {
  return <div>这是home页面</div>;
};
const About = () => {
  return <div>这是about页面</div>;
};

const App = () => {
  return (
    <>
      <h2>导航高亮</h2>

      <ul>
        <li>
          <NavLink
            to="/home"
            // isActive表示当前这一项是否被选中
            className={({ isActive }) => {
              console.log("home", isActive);
              return isActive ? "abc" : "";
            }}
          >
            首页
          </NavLink>
        </li>
        <li>
          <NavLink
            to="/about"
            className={({ isActive }) => {
              console.log("about", isActive);
              return isActive ? "abc" : "";
            }}
          >
            关于页
          </NavLink>
        </li>
      </ul>

      <Routes>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
      </Routes>
    </>
  );
};

export default App;
